#include <stdint.h>
#include <stdio.h>

static union {
  uint8_t buf[2];
  uint16_t uint16;
} endian = {{0x00, 0x3a}};

#define LITTLE_ENDIAN ((char)endian.uint16 == 0x00)
#define BIG_ENDIAN ((char)endian.uint16 == 0x3a)

int main() {
  uint8_t buf[2] = {0x00, 0x3a};

  if (LITTLE_ENDIAN) {
    printf("Little endian Machine: %x\n", ((uint16_t *)buf)[0]);
  } else {
    printf("Big endian Machine: %x\n", ((uint16_t *)buf)[0]);
  }
}
